{% extends 'front/index_base.html' %}
{% from 'common/_macros.html' import static %}


{% block head %}
    <link type=text/css rel="stylesheet" href="{{ static('front/css/index.css') }}">
    <link rel="stylesheet" type="text/css" media="screen and (max-device-width: 414px)" href={{ static('front/css/mobile_device.css') }} />
{% endblock %}

{% block body %}
    <div class="lg-container col-lg-7 col-lg-offset-1">
        <div class="jumbotron">
            <img class="img-responsive center-block" src="{{ url_for('static', filename="common/logo.png") }}" alt="">
            <p style="font-size: 19px">A forum based on Flask.</p>
            <p><a class="btn btn-warning" href="https://gitee.com/gjwlkj/flask" role="button">项目地址</a></p>
        </div>


        <div class="post-group">
            <hr>
            <ul class="post-group-head">

                {% if current_sort == 1 %}
                    <li class="active"><a href="{{ url_for('front.index', st=1, bid=board_id) }}">最新帖子</a></li>
                {% else %}
                    <li class=""><a href="{{ url_for('front.index', st=1, bid=board_id) }}">最新帖子</a></li>
                {% endif %}

                {% if current_sort == 2 %}
                    <li class="active"><a href="{{ url_for('front.index', st=2, bid=board_id) }}">精华帖子</a></li>
                {% else %}
                    <li><a href="{{ url_for('front.index', st=2, bid=board_id) }}">精华帖子</a></li>
                {% endif %}

                {% if current_sort == 3 %}
                    <li class="active"><a href="{{ url_for('front.index', st=3, bid=board_id) }}">点赞最多</a></li>
                {% else %}
                    <li><a href="{{ url_for('front.index', st=3, bid=board_id) }}">点赞最多</a></li>
                {% endif %}

                {% if current_sort == 4 %}
                    <li class="active"><a href="{{ url_for('front.index', st=4, bid=board_id) }}">评论最多</a></li>
                {% else %}
                    <li><a href="{{ url_for('front.index', st=4, bid=board_id) }}">评论最多</a></li>
                {% endif %}

            </ul>
            <hr>
            <ul class="post-item-group">
                {% for thread in threads %}
                    <li>
                        <div class="post-item">
                            <div class="author-avatar">
                                <img src="{{ thread.author.avatar or url_for('avatar', text=thread.author.username) }}"
                                     alt="">
                            </div>
                            <div class="post-item-right">
                                <p class="title">
                                    <a href="{{ url_for('front.thread_detail', thread_id=thread.id) }}">{{ thread.title }}</a>
                                    {% if thread.hlthread %}
                                        <span class="label label-warning">&nbsp精&nbsp</span>
                                    {% endif %}
                                </p>
                                <span class="post-item-info">
                                    <span class="glyphicon glyphicon-user" aria-hidden="true"></span><span
                                        class="thread-info">{{ thread.author.username }}</span>
                                    <span class="glyphicon glyphicon-time" aria-hidden="true"></span><span
                                        class="thread-info">{{ thread.create_time | timedelta }}</span>
                                    <span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span><span
                                        class="thread-info">{{ thread.likes | length }}</span>
                                    <span class="glyphicon glyphicon-comment" aria-hidden="true"></span><span
                                        class="thread-info">{{ thread.comments | length }}</span>
                                    <span><span
                                            class="thread-info pull-right hidden-in-mobile">{{ thread.board.name }}</span><span class="hidden-in-mobile pull-right glyphicon glyphicon-tag" aria-hidden="true"></span></span>
                                </span>
                            </div>
                        </div>
                    </li>
                {% endfor %}

            </ul>
        </div>
        <div style="text-align: center">
            {{ pagination.links }}
        </div>
    </div>

    <div class="sm-container col-lg-3">
        <div>
            <div class="publish" style="padding-bottom: 10px">
                <a href="{{ url_for('front.post') }}" class="btn btn-warning btn-block">发布帖子</a>
            </div>

            <div class="right-container hover-style">
                <div class="item-list-head">
                    <a style="padding: 0;" href="{{ url_for('front.index') }}"
                               class=" list-group-item"><h4>所有板块</h4></a>
                </div>

                <div class="">
                    {% for board in boards %}
                        {% if board.id == board_id %}
                            <a href="{{ url_for('front.index', bid=board.id) }}"
                               class="list-group-item" style="color: #eea236">{{ board.name }}<span
                                    class="badge">{{ board.threads | length }}篇</span></a>
                        {% else %}
                            <a href="{{ url_for('front.index', bid=board.id) }}"
                               class=" list-group-item">{{ board.name }}<span
                                    class="badge">{{ board.threads | length }}篇</span></a>
                        {% endif %}
                    {% endfor %}
                </div>
            </div>

            <div class="right-container hover-style" style="margin-top: 8px">
                <div class="item-list-head">
                    <h4>推荐阅读</h4>
                </div>

                <div class="">
                    {% for rec in recommend %}
                        <a href="{{ url_for('front.thread_detail', thread_id=rec.id) }}"
                           class="list-group-item">{{ rec.title }}<span
                                class="badge">{{ rec.likes | length }}赞</span></a>
                    {% endfor %}
                </div>
            </div>

        </div>
    </div>

{% endblock %}